<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="./css/share.css">
    <title>2021少数民族传统体育竞技</title>
</head>

<body>
    <div id="app">
        <div class="layout">
            <img src="./img/game1_12.png" alt="" class="bg-img">
            <div class="top-box">
                <img src="./img/share_img.png" alt="" class="share_img">
                <div class="photo-box">
                    <img src="./img/photo.png" alt="" class="photo">
                    <img src="./img/photo.png" alt="" class="photo">
                    <img src="./img/photo.png" alt="" class="photo">
                    <img src="./img/photo.png" alt="" class="photo">
                    <img src="./img/photo.png" alt="" class="photo">
                </div>
            </div>
            <img src="./img/again_icon.png" alt="" class="icon again">
            <img src="./img/skill_icon.png" alt="" class="icon explain">
        </div>
    </div>

    <script src="./js/jquery.js"></script>
    <script src="./js/request.js"></script>
    <script src="https://res2.wx.qq.com/open/js/jweixin-1.6.0.js"></script>
    <script>
        $('.again').on('click', function () {
            location.href = `game${localStorage.getItem('progress')}.html`
        })
        $('.explain').on('click', function () {
            location.href = 'http://youxi.haiqikj.com/explain.html'
        })
        let key = (locMemory.localStorage.getItem('progress') | 0)
        let type = key == 1 ? 'tree' : key == 2 ? 'jump' : 'dance'
        request('share_page/', {
            zm_token: localStorage.user_token,
            _zm_post_type: 'ajax',
            item_type: type
        }).then(res => {
            let list = res.rsm.help_list
            list.map((item, index) => {
                if (item.headimg_url) {
                    document.getElementsByClassName('photo')[index].src = item.headimg_url
                }
            })
        })
        request('get_share_sign/', {
            zm_token: localStorage.user_token,
            _zm_post_type: 'ajax',
            url: location.href
        }).then(res => {
            wx.config({
                debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
                appId: res.rsm.appId, // 必填，公众号的唯一标识
                timestamp: res.rsm.timestamp, // 必填，生成签名的时间戳
                nonceStr: res.rsm.nonceStr, // 必填，生成签名的随机串
                signature: res.rsm.signature, // 必填，签名
                jsApiList: ['onMenuShareTimeline',
                    'onMenuShareAppMessage',
                    'onMenuShareQQ',
                    'onMenuShareWeibo',
                    'onMenuShareQZone',
                    'onMenuShareTimeline',
                    'updateAppMessageShareData',
                    'hideOptionMenu',
                    'showOptionMenu',
                    'hideMenuItems',
                    'showMenuItems',
                    'hideAllNonBaseMenuItem',
                    'showAllNonBaseMenuItem',
                ] // 必填，需要使用的JS接口列表
            });
            wx.ready(function () { //需在用户可能点击分享按钮前就先调用
                wx.updateAppMessageShareData({
                    title: '2021少数民族传统体育竞技', // 分享标题
                    desc: '邀你一起参与游戏，赢取现金红包！', // 分享描述
                    link: `http://youxi.haiqikj.com?share_token=${res.rsm.share_token}&item_type=${type}`, // 分享链接，该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
                    imgUrl: './img/share_img_bg.png', // 分享图标
                    success: function () {
                        console.log('分享成功');
                    }
                })
            });
        })
    </script>
</body>

</html>